perm filename A78.TEX[106,RWF] blob sn#807784 filedate 1985-09-20 generic text, type C, neo UTF8
COMMENT ⊗   VALID 00003 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00002 00002	\magnification\magstephalf
C00006 00003	\def\drawat#1#2#3{\vtop{\kern#2\rlap{\kern#1#3}}} %#3 goes in hbox
C00011 ENDMK
C⊗;
\magnification\magstephalf
\input macro.tex
\def\today{\ifcase\month\or
  January\or February\or March\or April\or May\or June\or
  July\or August\or September\or October\or November\or December\fi
  \space\number\day, \number\year}
\baselineskip 14pt
\rm
\line{\sevenrm a78.tex[106,phy] \today\hfill}

\bigskip
\noindent {\bf Numerical Precision.}

You may have noticed that a Pascal program fragment like

\medskip
{\obeylines\obeyspaces\let =\ \tt\parskip0pt
READ(X) : WRITE(X)
}

\medskip\noindent
sometimes prints a slightly different value from what it reads. 
Similarly, if one program executes {\tt WRITE(X)} to a~file, and later
the same or another program executes {\tt READ(Y)} on that portion of
the fill, the values of~{\tt X} and~{\tt Y} may differ slightly.
To illustrate, suppose the computer is~8B, so that representable 
numbers are of the form
$$\hbox{(integer in 128 $\ldt$ 255) $\times$ (integer power of 2).}$$
If {\tt X} is $130/128 =1.015625$, {\tt WRITE(X:4:2)} puts ``{\tt 1.02}'' 
on the
output file. This value is closer to $131/128=1.0234375$ than to 130/128,
so reading it will result in ${\tt X}=131/128$. 

Diagramatically, 

\vskip 1.5truein

Similarly, if the input file contains ``{\tt 1.004}'', {\tt READ(X)} gives
${\tt X}=129/128$, and then {\tt WRITE(X: )} gives ``{\tt 1.008}''. 

Diagramatically, 

\vskip 1.5truein

\noindent
More realistically, on a 27B machine, the real numbers are
$2↑a\cdot b$ with $2↑{26}≤b<2↑{27}$, so the representable numbers between
1 and~2 are separated by $2↑{-26}=1.49\times 10↑{-8}$. If printed numbers
are normally rounded to~7D, the separation of the printable values
is $10↑{-6}=100\times 10↑{-8}$, so there are about $100/1.49=67$ internal
values for each external one. Only rarely, when you print a number and then
read it, will you get exactly the same number.

{\narrower\smallskip\noindent
{\bf Exercise.} In a 27B machine, {\tt X} contains $1+335\cdot 2↑{-26}$. The
value is printed to~7D, and read back in again; it is then found to be
$1+336\cdot 2↑{-26}$. Explain.
\smallskip}

{\narrower\smallskip\noindent
{\bf Answer:} The original value is $1.00000499188$, which rounds in 7D
to $1.000005$,
which is closer to $1+336\cdot 2↑{-26}=1.00000500679$.
\smallskip}

\bigskip
\line{\copyright 1985 Robert W. Floyd\hfill}
\line{First draft (not published) March 28, l985.\hfill}

\vfill\eject

\def\drawat#1#2#3{\vtop{\kern#2\rlap{\kern#1#3}}} %#3 goes in hbox

\newdimen\digitwidth
 \setbox0=\hbox{\rm0}
 \digitwidth=\wd0
\def\qtoblank%change ? to invisible digit
 {\catcode`?=\active
 \def?{\kern\digitwidth}}
%{\qtoblank ... 0.12579?58421?05.}
%\catcode'?=\other
%restores normal ?
%place { } around area that you wish to use \qtoblank
%or else say
%\catcode'?=\other %restores normal ?

\newdimen\unit
\def\point#1 #2 {\rlap{\kern#1\unit
  \raise#2\unit\hbox to 0\unit{\hss$\scriptstyle\bullet$\hss}}}
\def\ycoord#1 {\rlap{\kern -0.2\unit
 \raise#1\unit\hbox{#1}}}
\def\xcoord#1 {\rlap{\kern#1\unit
 \lower0.2\unit\hbox to 0\unit
 {\hss #1\hss}}}


\def\fnc#1{\mathop{\rm #1}\nolimits}
%usage: to get erf(x), write $\fnc{erf}(x)$


$$\vcenter{\hbox{\unit=1in
%$$\vbox{\hbox{\unit=1in
\point 0 1
\point 0.5 1
\point 1.0 1
\point 1.5 1
\point 2.0 1
\point 2.5 1
\point 3.0 1
\point 3.5 1
\point 0 0
\point 0.39 0
\point 0.78 0
\point 1.17 0
\point 1.56 0
\point 1.95 0
}}$$

\bigskip
$$\vcenter{\halign{\lft{#}\qquad&$\ctr{#}$\xskip&$\ctr{#}$\xskip%
&$\ctr{#}$\xskip&$\ctr{#}$\xskip%
&$\ctr{#}$\xskip&$\ctr{#}$\xskip%
&$\ctr{#}$\xskip&$\ctr{#}$\qquad%
&$\ctr{#}$\xskip\qquad&$\ctr{#}$\xskip\qquad&$\ctr{#}$\xskip\qquad&\ctr{#}\cr
&1&&1.01&&1.02&&1.03&&1.04&1.05&1.06\cr
Decimal\cr
\noalign{\bigskip}
Binary\cr
&1&{129\over 128}&&{130\over 128}&&{131\over 128}\cr}}$$

\bigskip
%$$\vbox{\hbox{\unit=1in
$$\vcenter{\hbox{\unit=1in
\point 0 1
\point 0.5 1
\point 1.0 1
\point 1.5 1
\point 2.0 1
\point 2.5 1
\point 3.0 1
\point 3.5 1
\point 4.0 1
\point 4.5 1
\point 0 0
\point 3.91 0
}}$$


\bigskip
$$\vcenter{\halign{\lft{#}\quad&$\ctr{#}$\qquad&$\ctr{#}$\xskip\quad%
&$\ctr{#}$\xskip&$\ctr{#}$\xskip%
&$\ctr{#}$\xskip&$\ctr{#}$\xskip%
&$\ctr{#}$\xskip&$\ctr{#}$\xskip%
&$\ctr{#}$\xskip&$\ctr{#}$\cr
&1&1.001&1.002&1.003&1.004&1.005&1.006&1.007&1.008&1.009\cr
Decimal\cr
\noalign{\bigskip}
Binary\cr
&1&&{129\over 128}\cr}}$$

\bye